<?php

require_once "../include/image/imageInRow.php";
require_once "../include/image/imageInList.php";
require_once "../include/image/image.php";
	
class galleryBuilder
{
	//properties
	//private $folderName;
	private $imageArray;
	private $galleryTitle = "";
	private $isSelectable = false;
	private $pictureHeight;
	private $pictureWidth;
	
	public function __construct($galleryTitle, $imageArray, $size)
	{
		//$this->folderName = '../images' .  '/' . $newFolderName . '/';
		$this->imageArray = $imageArray;
		$this->galleryTitle = $galleryTitle;
		switch($size)
		{
			case "SMALL":
				$this->pictureWidth = "75px";
				$this->pictureHeight = "75px";
				break;
			case "LARGE":
				$this->pictureWidth = "150px";
				$this->pictureHeight = "150px";
				break;
			case "LARGER":
				$this->pictureWidth = "300px";
				$this->pictureHeight = "300px";
				break;
			default:
				$this->pictureWidth = "";
				$this->pictureHeight = "";
				break;
		}
	}
	
	public function setSelectable()
	{	
		$this->isSelectable = true;
	}
	
	public function printGalleryInList()
	{
		$toEcho = "";

		$toEcho .= $this->printHeader();
		$toEcho .= '<ul class="photoGallery">';

		foreach($this->imageArray as $value)
		{
			$currentImage = new imageInList($value);
			if($this->isSelectable) $currentImage->setSelectable();
			$toEcho .= $currentImage->printImage($this->pictureWidth, $this->pictureHeight);
		}
		$toEcho .= '</ul>';
		echo $toEcho;
		return;
	}
	
	public function printGalleryInRow()
	{		
		$toEcho = "";
		$toEcho .= $this->printHeader();
		$toEcho .= '<table class="galleryInRow">';
		$toEcho .= '<tr>';

		foreach($this->imageArray as $value)
		{
			$currentImage = new imageInRow($value);
			$toEcho .= $currentImage->printImage($this->pictureWidth, $this->pictureHeight);
		}
		$toEcho .= '</tr>';
		$toEcho .= '</table>';
		echo $toEcho;
		return;
	}
	
	public function printGalleryInColumn()
	{		
		$toEcho = "";
		$toEcho .= $this->printHeader();
		$toEcho .= '<ul class="listPictureToComment">';

		foreach($this->imageArray as $key=>$value)
		{
			$toEcho .= "<li>";
			$currentImage = new Image($value,false);
			$toEcho .= "<div class='description'>";
			$toEcho .= $currentImage->printImage($this->pictureWidth, $this->pictureHeight);
			$toEcho .= "</div>";
			$toEcho .= "<div class='description'>";
			$toEcho .= "Title:";
			$toEcho .= "<BR/>";
			$toEcho .= "<input type='text' name='desciptionTitle".$key."' class='pictureTitle'></textarea>";
			$toEcho .= "<BR/>";
			$toEcho .= "Description:";
			$toEcho .= "<BR/>";
			$toEcho .= "<textarea name='desciptionText".$key."' class='pictureText'></textarea>";
			$toEcho .= "</div>";
			$toEcho .= "</li>";
		}
		$toEcho .= '</ul>';
		echo $toEcho;
		return;
	}
	
	private function printHeader()
	{
		if($this->galleryTitle != ""){
			return "<h2>".$this->galleryTitle."</h2>";
		}
	}
}

?>